package pl.put.to.classification;

import java.io.IOException;

import pl.put.to.classification.SGD.ZawiasSGDClassification;
import pl.put.to.classification.data.DataSet;
import pl.put.to.classification.data.DataSetManager;
import pl.put.to.classification.verification.error.BooleanErrorVerifcator;
import pl.put.to.classification.verification.error.ZawiasErrorVerificator;

public class ZawiasSGDEntryPoint {
	public static void main(String[] args) {
		
		try {
			allDataZawiasError();
			
			allDataBooleanError();
			
			halfDataBooleanError();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private static void allDataZawiasError() throws IOException {
		System.out.println("Whole data, zawias error:");
		ZawiasSGDClassification SGD = new ZawiasSGDClassification(new ZawiasErrorVerificator());
		
		DataSet data = new DataSet("data/spambase.data");
		
		SGD.train(data, data);
	}
	
	private static void allDataBooleanError() throws IOException {
		System.out.println("Whole data, 0/1 error:");
		ZawiasSGDClassification SGD = new ZawiasSGDClassification(new BooleanErrorVerifcator());
		
		DataSet data = new DataSet("data/spambase.data");
		
		SGD.train(data, data);
	}

	private static void halfDataBooleanError() throws IOException {
		System.out.println("Half train and half test data, 0/1 error:");
		ZawiasSGDClassification SGD = new ZawiasSGDClassification(new BooleanErrorVerifcator());
		
		DataSet data = new DataSet("data/spambase.data");
		DataSetManager dataSetManager = new DataSetManager(data);
		dataSetManager.divideDataSetIntoTrainAndTest(0.5);
		
		SGD.train(dataSetManager.getTrainDataSet(), dataSetManager.getTestDataSet());
	}
}
